﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CreateJM
{
    public class WordFrequencyInfo
    {
        public string Word { get; set; }//字

        /// <summary>
        /// 原一级简码1级，原键面字2级，原二级简码3级， 一级常用2000字4级， 二级常用1500字5级；7000+8105+GB18030_2000+笔画、部首jvm第6级为6级，其他CJK为7级
        /// </summary>
        public int Frequency1 { get; set; }
        /// <summary>
        /// 字频
        /// </summary>
        public int Frequency2 { get; set; }


        public WordFrequencyInfo(string word, int wordFrequency1, int wordFrequency2)
        {
            this.Word = word;
            this.Frequency1 = wordFrequency1;
            this.Frequency2 = wordFrequency2;
        }


    }

    public class WordFrequencySort
    {

            //单字按常用字级别、字频排序
            public static int SortByFrequency(WordFrequencyInfo WordFrequency1, WordFrequencyInfo WordFrequency2)
            {
                if (WordFrequency1.Frequency1.CompareTo(WordFrequency2.Frequency1) != 0)
                    return (WordFrequency1.Frequency1.CompareTo(WordFrequency2.Frequency1));//按常用级别升序
                else if (WordFrequency1.Frequency2.CompareTo(WordFrequency2.Frequency2) != 0)
                    return -(WordFrequency1.Frequency2.CompareTo(WordFrequency2.Frequency2));//按字频降序
                else if (WordFrequency1.Word.CompareTo(WordFrequency2.Word) != 0)
                    return (WordFrequency1.Word.CompareTo(WordFrequency2.Word));//按字升序
                else
                    return 1;
            }
    }
}
